import operate from '@dfeidao/atom-nodejs/db/operate';
import log from '@dfeidao/atom-nodejs/logger/log';
import { systemid } from '../../atom/config';
interface Message {
	train_number: string;
	safety_department_no: string;
	safety_department_name: string;
}


// 表名	training_objects
// 标题	培训对象
// 字段名称	字段标题	字段类型	字段长度	是否为空	是否主键
// _id	id	string	50	ⅹ	√
// productid	产品ID	string	50	√	ⅹ
// train_number	培训编号	string	64	√	ⅹ
// safety_department_no	安全部门编号	string	64	√	ⅹ
// safety_department_name	安全部门名称	string	64	√	ⅹ

export default async function atom(msg: Message, action_id: string, session_id: string) {
	log(`Service begin`);
	const { exec, insert } = await operate(action_id, session_id, systemid);
	insert('training_objects', { 'safety_department_no': msg.safety_department_no, 'safety_department_name': msg.safety_department_name });
	const res = await exec();
	log(`Service end`);
	return res;
}
